package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    public Page<DishVO> PageQuery(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    @Select("select * from dish where id=#{id};")
    Dish getById(Long id);

    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);
    @Select("select * from dish_flavor where dish_id=#{id};")
    List<DishFlavor> getFlavorsById(Long id);
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    void updateStatus(Long id, Integer status);
    @Select("select * from dish where category_id=#{categoryId};")
    List<Dish> getDishesByCategoryId(Long categoryId);
    @Select("select * from dish where category_id=#{categoryId};")
    List<Dish> list(Dish dish);

    Integer countByMap(Map map);
}
